package com.tywj.test.library;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class TimeUtils {


    //时间格式转换
    public static String TimeAdd(String oldTime, String add) {
        int addMit = Integer.parseInt(add);
        //注意大写为 24小时格式为 ("HH :mm")      12小时格式小写为（"hh:mm"）
        DateFormat df = new SimpleDateFormat("HH:mm", Locale.CHINA);
        Date date = null;
        try {
            date = df.parse(oldTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        Date expireTime = new Date(date.getTime() + addMit * 60 * 1000);
        String newTime = df.format(expireTime);
        return newTime;
    }

    public static void main(String[] args) throws ParseException {
        String timeAdd = TimeAdd("12:30", "7");
        System.out.println(timeAdd);
    }
}